package day09API.Exception;

/**
 * @author DBX
 * @effect
 * @date 2021/8/27 0027 - 17:18
 */
public class TryCatchDemo1 {
    public static void main(String[] args) {
        System.out.println("程序开始");
//        String str = "";
        String str = "abc";
        try {
            System.out.println(str.length());
            System.out.println(str.charAt(0));
//            System.out.println(Integer.parseInt(str));
            byte[] bytes = str.getBytes("UTF-8");
            System.out.println(bytes.length);
            System.out.println(bytes[0]);
        }catch (StringIndexOutOfBoundsException e){
            System.err.println("数组下标越界异常");
        }catch(NumberFormatException e){
            System.err.println("格式转化异常");
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("程序结束");
    }

}
